<template> 
    <div class='layout'>
        <Layout>
            <Menu mode="horizontal" :theme="theme1" active-name="1">
                <img :src="logo[0]" class='logo' alt="LOGO"/>
            </Menu>
            <Content>
                <div class='content'>
                    <div class='content_bg'>
                        <Card icon="log-in" class='logoForm' title="欢迎登录" :bordered="false">
                            
                        
                        <Form ref="formInline"  :model="formInline" :rules="ruleInline" inline>
                            <FormItem prop="user">
                                <Input type="text" v-model="formInline.user" placeholder="Username">
                                    <Icon type="ios-person-outline" slot="prepend"></Icon>
                                </Input>
                            </FormItem>
                            <FormItem prop="password">
                                <Input type="password" v-model="formInline.password" placeholder="Password">
                                    <Icon type="ios-lock-outline" slot="prepend"></Icon>
                                </Input>
                            </FormItem>
                            <FormItem type="flex" justify="center">
                                <Button type="primary" @click="handleSubmit('formInline')" long>登录</Button>
                            </FormItem>
                        </Form>
                        </Card>
                    </div>
                </div>
            </Content>
            <Footer>
                <Row type="flex" justify="center" align="bottom" class="code-row-bg">
                    版权所有：海东水务集团  Copyright©2017
                </Row>
                <Row type="flex" justify="center" align="bottom" class="code-row-bg" style='margin-top:16px;'>
                    <Col><img :src="logo[1]" />地址：海东市平安大道38号 | </Col>
                    <Col><img :src="logo[2]" />电话：0732-323232121 |</Col>
                    <Col><img :src="logo[3]" />邮箱：Administrator@haidong.com |</Col>
                    <Col><img :src="logo[4]" />QQ:3213211223</Col>
                </Row>
            </Footer>
        </Layout>
    </div>
</template>
<style lang="less" scope>

@import './login.less';
</style>
<script>
import logoImg from '@/assets/logo.png';

import location from '@/assets/icon_location.png';
import phone from '@/assets/icon_phone.png';
import email from '@/assets/icon_email.png';
import qq from '@/assets/qq.png';

    export default {
        data() {
            return {
                theme1:'light',
                logo:[logoImg,location,phone,email,qq],
                formInline: {
                    user: '',
                    password: ''
                },
                ruleInline: {
                    user: [
                        { required: true, message: '请输入正确用户名', trigger: 'blur' }
                    ],
                    password: [
                        { required: true, message: '请输入密码', trigger: 'blur' },
                        { type: 'string', min: 6, message: '密码长度至少为6位', trigger: 'blur' }
                    ]
                }
            }
        },
        methods: {
            handleSubmit(name) {
                this.$refs[name].validate((valid) => {
                    if (valid) {
                        var that = this;
                        localStorage.setItem('userName',this.formInline.user);
                        this.$Message.success('Success!');
                        setTimeout(function(){
                            that.$router.push({ path: 'Home' }) 
                        },500)
                    } else {
                        this.$Message.error('Fail!');
                    }
                })
            }
        },
        mounted() {
          
        }
    }
</script>